//:C03:StringReplace.cpp
// Simple find-and-replace in strings.
#include <cassert>
#include <string>
using namespace std;

int main()
{
	string s("A piece of text");
	string tag("$tag$");
	s.insert(8, tag + ' ');
	assert(s == "A piece $tag$ of text");
	int start = s.find(tag);
	assert(start == 8);
	assert(tag.size() == 5);
	s.replace(start, tag.size(), "hello there");
	assert(s == "A piece hello there of text");
}